package com.hy.convenient.config;

import com.hy.convenient.common.CommonData;
import com.hy.convenient.common.LayuiToTable;
import com.hy.convenient.common.VipEnum;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.connector.RequestFacade;
import org.apache.catalina.connector.ResponseFacade;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.jws.WebResult;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @Description TODO
 * @className HttpErrorController
 * @Author hdy
 * @Date 2020-12-28 17:56
 * @Version 1.0
 */
@Slf4j
@RestController
public class HttpErrorController implements ErrorController {

    private final static String ERROR_PATH = "/error";
    @ResponseBody
    @RequestMapping(path  = ERROR_PATH )
    public Map<String, Object> error(HttpServletResponse response, RequestFacade request, Exception ex){
//        log.info("访问/error" + "  错误代码："  + );
//        获取到转发前的请求路径BasicErrorController
        String requestURI =  request.getRequestURI();
        return   LayuiToTable.business_fail(response.getStatus());
    }
    @Override
    public String getErrorPath() {
        return ERROR_PATH;
    }



}